package weaver.interfaces.zkwz;

import com.weaver.general.BaseBean;
import com.weaver.general.Util;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @Title: ecology-idea
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2022-09-23
 * @Description: 离职申请单更新应出勤天数和实际出勤天数到人力资源表
 * @ModifyLog:
 **/

public class WeaLzsqdAction extends BaseBean implements Action {

    @Override
    public String execute(RequestInfo requestInfo) {

        String requestid = requestInfo.getRequestid();
        String tablename =requestInfo.getRequestManager().getBillTableName();
        writeLog( ">>>>>>WeaLzsqdAction>>>>>requestid=" + requestid);
        RecordSet rs = new RecordSet();
        try {
            rs.executeQuery( "select * from " + tablename + " where requestid=?", requestid );
            rs.next();
            String xm = Util.null2String( rs.getString("xm"));
            String sqrq = Util.null2String( rs.getString("sqrq")).substring(0,7);
            rs.executeQuery("select count(resourceid) from kq_format_total where resourceid=? and workdays=1 and kqdate like '"+sqrq+"%'",xm);
            rs.next();
            String ycqts = Util.null2String(rs.getString(1));

            rs.executeQuery("select count(resourceid) from kq_format_total where resourceid=? attendancedays=0 and kqdate like '"+sqrq+"%'",xm);
            rs.next();
            String wcqts = Util.null2String(rs.getString(1));

            rs.executeUpdate("update hrmresource set TEXTFIELD1=?,TEXTFIELD2=? where id=?",ycqts,wcqts,xm);
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "Action接口异常！" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }
}
